<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
</head>
<body>
<!--一定要设定div的高度和宽度一边撑起图标-->
<div id="echart" style="height: 300px; width: 600px"></div>

</body>
<!-- jQuery -->
<script src="plugins/jquery/jquery.min.js"></script>
<!-- sweet alert -->
<script src="plugins/sweetalert/sweetalert.min.js"></script>
<script src="dist/js/public.js"></script>
<!-- Echarts-->
<script src="plugins/echarts/echarts.min.js"></script>
<script type="text/javascript">
    //图表初始化
    var echarts = echarts.init(document.getElementById('echart'));
    initEcharts();

    function initEcharts() {
        echarts.clear();
        echarts.showLoading({text: '正在努力的读取数据中...'});
        // debugger
        $.ajax({
            url: "/echarts/bar",
            type: "post",
            success: function (data) {
                var option = eval("("+data+")");
                echarts.setOption(option);
                echarts.hideLoading();
            }
        })
    }
</script>
</html>